home *** CD-ROM | disk | FTP | other *** search
- //a_Character sets and such
-
- #ifndef __RTTI__
- #error Must have RTTI enabled in order to use matrix derived classes
- #endif
-
- //a_Include the character sets to use
- #include "a_cseng.h" //a_English set
- #include "a_csnum.h" //a_Number/Symbol set
-
- ////////////////////////////////////////////////////
- // ACharSetItem - the character set to use
- ////////////////////////////////////////////////////
- class ACharSetItem : public ADataItem
- {
- public:
- BYTE *pbaaChar, //a_The character set array of arrays (a matrix)
- *pbaMap; //a_The map to the character
-
- int cType, //a_One letter description of the font in use
- iCharWidth, //a_The width of all character matrices
- iCharHeight, //a_The height of all character matrices
- iLineHeight, //a_Height of the line to include all characters without clipping
- iMapSize, //a_Size of the mapping array (ie # of characters)
- iArraySize, //a_Each array of the character is iCharWidth * iCharHeight / 8
- iBaseline; //a_The baseline for all the characters (suggested by the set designer)
-
- ACharSetItem(void)
- {
- cType = '\x0';
- pbaaChar =pbaMap =NULL;
- iMapSize = - 0x1;
- iCharWidth = iCharHeight = iArraySize = -0x1;
- iBaseline = iLineHeight = -0x1;
- }
-
- int csetIsValid(void)
- {
- //a_Superfiscial validation
- if (!cType) return 0x0;
- if (!pbaaChar || !pbaMap || iMapSize < 0x0 || iArraySize < 0x0) return 0x0;
- if (iCharWidth < 0x0 || iCharHeight < 0x0 || iBaseline < 0x0 || iLineHeight < 0x0) return 0x0;
- return 0x1;
- }
-
- //a_Declares debug/dump related functions
- #ifdef _DEBUG_DUMP_
- void dump(void); //a_Debugging dump, when _DEBUG_DUMP_ is set
- #endif
- };
-
- //a_Macro for setting the CHARSET array with global variables in a_csXXX.h files
- #define SET_CHARSET(classCS, type) do { \
- (##classCS).pbaaChar = (BYTE *)BYTEMATRIX_CHARSET_##type; \
- (##classCS).pbaMap = (BYTE *)BYTEARRAY_MAP_##type; \
- (##classCS).iMapSize = CSET_MAPSIZE_##type; \
- (##classCS).cType = CSET_TYPE_##type; \
- (##classCS).iArraySize = CSET_ARRAYSIZE_##type; \
- (##classCS).iCharWidth = CSET_CHARSIZE_X_##type; \
- (##classCS).iCharHeight = CSET_CHARSIZE_Y_##type; \
- (##classCS).iBaseline = CSET_CHARBASELINE_##type; \
- (##classCS).iLineHeight = CSET_CHARLINEHEIGHT_##type; \
- } while(0x0);
-
- //a_Macros to get size of the charset
- #define CHARSET_WIDTH(type) (CSET_CHARSIZE_X_##type)
- #define CHARSET_HEIGHT(type) (CSET_CHARSIZE_Y_##type)
-
- /////////////////////////////////////////////////////////////
- // ACharSetList - contains the character sets
- /////////////////////////////////////////////////////////////
- class ACharSetList : public AList
- {
- public:
- void cslInitialize(const char *pccFontOrder);
- BYTE *cslGetArrayInCharSet(char cGet, ACharSetItem *&pcsiCurrent, const char *pccSets = NULL);
- ACharSetItem *cslGetSetFromType(char cType);
-
- //a_Declares debug/dump related functions
- #ifdef _DEBUG_DUMP_
- void dump(void); //a_Debugging dump, when _DEBUG_DUMP_ is set
- #endif
-
- protected:
- void _cslAddAfter(ACharSetItem *pcsiAdd, char cAddAfter);
-
- };
-
- /////////////////////////////////////////////////////////////////////////
- // AChar - contains 1 character in a bit-packed ABitmatrix-type object
- /////////////////////////////////////////////////////////////////////////
- class AChar : public ABitMatrix
- {
- public:
- AChar()
- {
- m_iBitWidth = m_iBitHeight = m_iBitBaseline = 0x0;
- }
- virtual ~AChar() {}
-
- //a_Sets up this class for the character specified by a BYTE array using the params
- void charSet(BYTE *pbChar, int iArraySize, int iSX, int iSY);
- int charGetWidthOnly(BYTE *pbChar, int iArraySize, int iSX) const;
-
- //a_Access members
- int charGetBitWidth(void) const { return m_iBitWidth; }
- int charGetBitHeight(void) const { return m_iBitHeight; }
- int charGetBitBaseline(void) const { return m_iBitBaseline; }
-
- protected:
- //a_NOTE: m_iX and m_iY are the physical dimensions of the character set
- int m_iBitWidth, //a_The actual width specified by the characted
- m_iBitHeight, //a_The actual height specified by the character
- m_iBitBaseline; //a_The baseline of this character (spoecified by the character)
-
- };
-
- /////////////////////////////////////////////////////////////////////////////////////////
- // ACharSetMatrix - Character set matrix based on ABitMatrix and uses AChar which is based in ABitMatrix
- /////////////////////////////////////////////////////////////////////////////////////////
- class ACharSetMatrix : public ABitMatrix
- {
- public:
- ACharSetMatrix(const char *pccFonts = NULL);
- ~ACharSetMatrix();
-
- //a_Declares debug/dump related functions
- #ifdef _DEBUG_DUMP_
- void dump(void); //a_Debugging dump, when _DEBUG_DUMP_ is set
- #endif
-
- //a_Linked list of characters sets in use
- ACharSetList m_cslCharSets;
-
- //a_Character set based output. Works with a given ACharSet class
- //a_Map text top current set and map to ABitMatrix (see TEXTOUT structure above)
- //a_Simple wrapper for the extended one
- int csmTextOut(const char *pccOut, int iLength = -1, int iPX = 0x0, int iPY = 0x0, int iLineHeight = -1, int iBaseline = -1);
- //a_The full control one (a much better choice with more control)
- int csmTextOutEx(TEXTOUT& tOut); //a_Extended text out
-
- //a_Calculates the length of a string
- int csmGetTextExtent(const char *pccOut, int iLength = -1);
- int csmGetTextExtent(TEXTOUT &tOut);
-
- protected:
- //a_Basic validation routine
- int _csmIsValidTEXTOUT(TEXTOUT &tOut);
-
- };
-